From a364083f42dd68eb8ba3d9428f169eefe108b9f1 Mon Sep 17 00:00:00 2001 From: robertlipe Date: Wed, 23 Oct 2013 03:29:26 +0000 Subject: [PATCH] Misc minor fixes for the !NEW_STRINGS case. --- gpsbabel/garmin_gpi.cc | 2 +- gpsbabel/lowranceusr.cc | 9 +++++++-- gpsbabel/mapsend.cc | 7 +++---- gpsbabel/raymarine.cc | 2 +- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/gpsbabel/garmin_gpi.cc b/gpsbabel/garmin_gpi.cc index a5342c5b9..1b873f373 100644 --- a/gpsbabel/garmin_gpi.cc +++ b/gpsbabel/garmin_gpi.cc @@ -1317,7 +1317,7 @@ enum_waypt_cb(const waypoint* ref) wpt->shortname = str; #else xfree(wpt->shortname); - wpt->shortname = str; + wpt->shortname = xstrdup(str); #endif } diff --git a/gpsbabel/lowranceusr.cc b/gpsbabel/lowranceusr.cc index e13e8e7bc..2f1e1d1f7 100644 --- a/gpsbabel/lowranceusr.cc +++ b/gpsbabel/lowranceusr.cc @@ -721,6 +721,7 @@ lowranceusr_waypt_disp(const waypoint* wpt) } else if (!wpt->description.isEmpty()) { name = wpt->description; #else + char* name = NULL; if ((! wpt->shortname) || global_opts.synthesize_shortnames) { if (wpt->description && global_opts.synthesize_shortnames) { name = mkshort_from_wpt(mkshort_handle, wpt); @@ -734,15 +735,19 @@ lowranceusr_waypt_disp(const waypoint* wpt) name = wpt->shortname; } +#if NEW_STRINGS text_len = name.length(); +#else + text_len = strlen(name); +#endif if (text_len > MAXUSRSTRINGSIZE) { text_len = MAXUSRSTRINGSIZE; } gbfputint32(text_len, file_out); - gbfwrite(CSTR(name), 1, text_len, file_out); + gbfwrite(CSTRc(name), 1, text_len, file_out); if (global_opts.debug_level >= 1) { - printf(MYNAME " waypt_disp: Waypt name = %s\n", CSTR(name)); + printf(MYNAME " waypt_disp: Waypt name = %s\n", CSTRc(name)); } /** diff --git a/gpsbabel/mapsend.cc b/gpsbabel/mapsend.cc index 7a6f842a6..4c3103576 100644 --- a/gpsbabel/mapsend.cc +++ b/gpsbabel/mapsend.cc @@ -278,7 +278,6 @@ mapsend_waypt_pr(const waypoint* waypointp) QString sn = global_opts.synthesize_shortnames ? mkshort_from_wpt(mkshort_handle, waypointp) : waypointp->shortname; - QString tmp; /* * The format spec doesn't call out the character set of waypoint @@ -296,8 +295,8 @@ mapsend_waypt_pr(const waypoint* waypointp) */ - tmp = mkshort(wpt_handle, sn); - gbfputpstr(tmp, mapsend_file_out); + QString tmp1 = mkshort(wpt_handle, sn); + gbfputpstr(tmp1, mapsend_file_out); #if NEW_STRINGS c = waypointp->description.length(); @@ -307,7 +306,7 @@ mapsend_waypt_pr(const waypoint* waypointp) gbfputc(c, mapsend_file_out); gbfwrite(CSTR(waypointp->description), 1, c, mapsend_file_out); #else - tmp = waypointp->description; + char* tmp = waypointp->description; if (tmp) { c = strlen(tmp); } else { diff --git a/gpsbabel/raymarine.cc b/gpsbabel/raymarine.cc index cbe6051bc..a44f4403c 100644 --- a/gpsbabel/raymarine.cc +++ b/gpsbabel/raymarine.cc @@ -311,7 +311,7 @@ register_waypt(const waypoint* ref, const char is_rtept) } } - wpt->extra_data = (void*)mkshort(hshort_wpt, CSTR(wpt->shortname)); + wpt->extra_data = (void*)mkshort(hshort_wpt, CSTRc(wpt->shortname)); waypt_table[waypt_table_ct] = (waypoint*)wpt; waypt_table_ct++; -- 2.30.2